<?php

namespace app\payment;

class PayFactory
{
    const WECHAT = 'wechat';

    const ALIPAY = 'ali';

    const BALANCE = 'balance';
    const INTEGRAL = 'integral';

    const CONTRIBUTION = 'contribution';

    const FREEZE_INTEGRAL = 'freeze_integral';

    const RECHARGE_INTEGRAL = 'recharge_integral';

    const REGISTER_INTEGRAL = 'register_integral';

    const UNFREEZE_INTEGRAL = 'unfreeze_integral';

    const BORROW_INTEGRAL = 'borrow_integral';

    const REWARD_INTEGRAL = 'reward_integral';

    const RECHARGE_REGISTER_INTEGRAL = 'rr';

    const PAY_WAY_TEXT = [
        self::INTEGRAL => '积分',
//        self::FREEZE_INTEGRAL => '冻结积分',
        self::RECHARGE_INTEGRAL => '充值积分',
        self::REGISTER_INTEGRAL => '注册积分'
    ];

    public static function create($payWay): AbstractPay
    {
        $className = ucfirst(strtolower($payWay)) . 'Pay';

        $fullClassName = __NAMESPACE__ . "\\" . $className;

        if (class_exists($fullClassName)) {
            return new $fullClassName;
        }

        throw new \Exception('不支持的支付方式');
    }
}